package org.example.io;


import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.nio.charset.Charset;

public class TestBufferedInputStream {
    public static void main(String[] args) throws Exception{
        //创建字节缓冲输入流
        BufferedInputStream stream = new BufferedInputStream(new FileInputStream("D:\\tmp\\sort.txt"));
        //输出数据
        int len;
        while ((len = stream.read())!=-1){
            System.out.print((char) len);
        }
        System.out.println();

        //使用数组
        byte[] bytes = new byte[1024];
        len = 0;
        while ((len = stream.read(bytes))!=-1){
            System.out.print(new String(bytes,0,len));
        }
        System.out.println();

        //关闭流
        stream.close();

    }
}
